package com.ld.control.business.process.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ld.control.business.process.service.ProcessNodeExampleRunningParamService;
import com.ld.control.business.process.service.ProcessNodeExampleRunningService;
import com.ld.control.business.process.service.ProcessNodeExampleService;
import com.ld.control.business.process.vo.resp.ProcessNodeExampleDetailsResp;
import com.ld.control.business.process.vo.resp.ProcessNodeExampleRunningParamRespVo;
import com.ld.control.business.process.vo.resp.ProcessNodeExampleRunningRecordResp;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.common.vo.GeneratePageListVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 任务流程节点实例表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-05-21
 */
@Slf4j
@Tag(name = "任务运行数据相关接口")
@RestController
public class ProcessNodeExampleRunningController {

    @Autowired
    private ProcessNodeExampleRunningService processNodeExampleRunningService;

    @Autowired
    private ProcessNodeExampleRunningParamService processNodeExampleRunningParamService;

    @GetMapping("/api/centralControl/processNodeExampleRunning/getPageList")
    @Operation(summary = "获取任务节点运行数据列表")
    public ResultResponse<GeneratePageListVo<ProcessNodeExampleRunningRecordResp>> getProcessNodeExampleRunning(
            @Parameter(description = "任务实例id(从下拉框选择)") @RequestParam(required = false) Long taskExampleId,
            @Parameter(description = "流程实例id") @RequestParam(required = false) Long processExampleId,
            @Parameter(description = "任务实例编号code") @RequestParam(required = false) String taskExampleCode,
            @Parameter(description = "方法名称") @RequestParam(required = false) String sendMethodName,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "10")Integer size
    ) {
        IPage<ProcessNodeExampleRunningRecordResp> processNodeExampleRunningRecordRespIPage =
                processNodeExampleRunningService.getPageListByCondition(taskExampleId, processExampleId, taskExampleCode, sendMethodName, current, size);
        return ResultResponse.success(new GeneratePageListVo<>(processNodeExampleRunningRecordRespIPage));
    }

    @GetMapping("/api/centralControl/processNodeExampleRunning/getRunningParamList")
    @Operation(summary = "查询此命令的参数信息")
    public ResultResponse<GenerateListVo<ProcessNodeExampleRunningParamRespVo>> getRunningParamList(
            @RequestParam Long processNodeExampleRunningId
    ){
        List<ProcessNodeExampleRunningParamRespVo> processNodeExampleRunningParamRespVoList = processNodeExampleRunningParamService.getListByRunningId(processNodeExampleRunningId);
        return ResultResponse.success(new GenerateListVo<>(processNodeExampleRunningParamRespVoList));
    }
}

